using UnityEngine;

public class PlayerStateBehavior_Run : AbstractPlayerStateBehavior
{
	public static PlayerStateBehavior_Run instance;

	private PlayerStateBehavior_Run()
	{
	}

	public static PlayerStateBehavior_Run getInstance()
	{
		if (instance == null)
		{
			instance = new PlayerStateBehavior_Run();
		}
		return instance;
	}

	public override void enter(Player owner)
	{
		base.enter(owner);
		if (owner.getData_Speed() >= 9)
		{
			if (owner.getParaTeam().getIsOffense() && owner.IsCrossHalfCourt())
			{
				owner.playAnimation(AnimationName.player_run_fast, (float)owner.getData_Speed() * 0.111f, -1f);
			}
			else
			{
				owner.playAnimation(AnimationName.player_run, 1.5f * owner.getMoveSpeed() * 0.2f, -1f);
			}
		}
		else
		{
			owner.playAnimation(AnimationName.player_run, 1.5f * owner.getMoveSpeed() * 0.2f, -1f);
		}
		if (owner.isBallInHand())
		{
			Instance<Ball>.instance.do_rebound();
		}
	}

	public override void fixedUpdate(Player owner)
	{
		base.fixedUpdate(owner);
		if (Instance<Ball>.instance.isInState(BallState_Rebound.getInstance()) && Instance<Ball>.instance.isGetBall(owner.getPosition()))
		{
			Vector3 position = Instance<Ball>.instance.getPosition();
			if (position.y < 1.8f && !Instance<Court>.instance.isInState(CourtStateFreeThrow.getInstance()) && owner.teamType == TeamType.USER)
			{
				Instance<Court>.instance.OnGrabedRebound(owner);
			}
		}
	}
}
